
package com.liu.tools;

import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.client.j2se.MatrixToImageWriter;
import com.google.zxing.common.BitMatrix;

import java.io.File;

public class GetQR {
	 //content：要转换的内容
		//生成的二维码图片的绝对路径
		public static void buildQuickMark(String content, String path)
				throws Exception {
			try {
				BitMatrix byteMatrix = new MultiFormatWriter().encode(new String(
						content.getBytes(), "iso-8859-1"), BarcodeFormat.QR_CODE,
						200, 200);
				
				MatrixToImageWriter.writeToFile(byteMatrix, "jpg", new File(path+".jpg"));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
}